package com.agent.user.api.feign;

import com.agent.common.result.ApiResponse;
import com.agent.user.api.resp.UserResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;

/**
 * 用户Feign客户端
 * @author Jeff_Wan
 * @description 用户服务Feign接口
 */
@FeignClient(name = "agent-user", contextId = "user", path = "/api/users")
public interface UserFeignClient {

    /**
     * 根据ID获取用户信息
     * @param userId 用户ID
     * @return 用户信息
     */
    @GetMapping("/info/{userId}")
    ApiResponse<UserResp> getUserById(@PathVariable("userId") Long userId);

    /**
     * 根据邮箱获取用户信息
     * @param email 邮箱
     * @return 用户信息
     */
    @GetMapping("/info/{email}")
    ApiResponse<UserResp> getUserByEmail(@PathVariable("email") String email);

    /**
     * 根据用户名获取用户信息
     * @param username 用户名
     * @return 用户信息
     */
    @GetMapping("/info/{username}")
    ApiResponse<UserResp> getUserByUsername(@PathVariable("username") String username);

    /**
     * Google登录/注册
     * @param googleId Google账号ID
     * @param email 邮箱
     * @param username 用户名
     * @param avatarUrl 头像URL
     * @return 用户响应
     */
    @PostMapping("/google-login")
    ApiResponse<UserResp> createOrUpdateByGoogleId(
            @RequestParam("googleId") String googleId,
            @RequestParam("email") String email,
            @RequestParam("username") String username,
            @RequestParam("avatarUrl") String avatarUrl);

    /**
     * 修改用户会员身份
     * @param userId 用户id
     * @param planType 会员类型
     * @param subscriptionType 订阅类型
     * @return 状态
     */
    @GetMapping("/update/membership")
    ApiResponse<UserResp> updateMembership(
            @RequestParam("userId")Long userId,
            @RequestParam("planType")String planType,
            @RequestParam("subscriptionType")String subscriptionType,
            @RequestParam("planType") LocalDateTime startDate,
            @RequestParam("subscriptionType")LocalDateTime endDate);
}